<?php

/**
 * This is the model class for table "modes".
 *
 * The followings are the available columns in table 'modes':
 * @property string $id
 * @property string $mode
 * @property string $theme
 * @property integer $ordre
 * @property boolean $manuel
 * @property boolean $ordrePos
 * @property boolean $ordreNeg
 * @property integer $ordreTempo
 */
class Mode extends CActiveRecord {


    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Mode the static model class
     */
    public static function model($className = __CLASS__) {
	  return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
	  return 'chauffage_modes';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
	  // NOTE: you should only define rules for those attributes that
	  // will receive user inputs.
	  return array(
		array('mode, theme', 'required'),
		array('ordre, ordreTempo', 'numerical', 'integerOnly' => true),
		array('id', 'length', 'max' => 15),
		array('mode', 'length', 'max' => 20),
		array('theme', 'length', 'max' => 1),
		array('manuel, ordrePos, ordreNeg', 'safe'),
		  // The following rule is used by search().
		  // Please remove those attributes that should not be searched.
		  //array('id, mode, theme, ordre, manuel, ordrePos, ordreNeg, ordreTempo', 'safe', 'on'=>'search'),
	  );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
	  // NOTE: you may need to adjust the relation name and the related
	  // class name for the relations automatically generated below.
	  return array(
	  );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
	  return array(
		'id' => 'ID',
		'mode' => 'Mode',
		'theme' => 'Theme',
		'ordre' => 'Ordre',
		'manuel' => 'Manuel',
		'ordrePos' => 'Ordre Pos',
		'ordreNeg' => 'Ordre Neg',
		'ordreTempo' => 'Ordre Tempo',
	  );
    }

    public function getPicto($class = '', $currentMode = '') {

	  if($this->id == $currentMode){$class .= ' automode';}
	  return CHtml::tag('div', array('class' => $this->id . ($class != '' ? ' '.$class : '') ), '&nbsp;');
    }

}